<template>
	<view>
		<view class="top">
			<view class="user">
				<view class="user-info">
					<hb-head width="72" height="72" :avatar="userInfo.avatar"></hb-head>
					<view class="user-info-name">
						<text class="user-name">{{userInfo.nickname}}</text>
						<text class="user-id">ID：{{userInfo.id}}</text>
					</view>
					<view class="user-grade">
						<view class="grade-box">
							{{userInfo.partner_name}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="moneyChange">
			<view class="content">
				<view class="title flex flexSpace">
					<view class="team_num">{{$t('agency.teamNum')}}：<text>{{alsolt.count}}</text></view>
					<view class="team_level">
						<image src="@/static/my/vip.png" mode="" class="sign"></image>
						<text v-if="userInfo.partner_name == 'LV3'">{{$t('agency.LV3')}}</text>
						<text v-if="userInfo.partner_name == 'LV2'">{{$t('agency.LV2')}}</text>
						<text v-if="userInfo.partner_name == 'LV1'">{{$t('agency.LV1')}}</text>
					</view>
				</view>
				<view class="flexWrap">
					<view class="item">
						<text>{{$t('agency.cumulative')}}{{Number(alsolt.phs_wei)}}：</text>
						<view class="price">{{Number(alsolt.phs)}}</view>
					</view>
					<view class="item">
						<text>{{$t('yuebao.income')}}（coin）：</text>
						<view class="price">{{Number(alsolt.partnerCount)}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="priceChange">
			<view class="Tabprice">
				<text>{{$t('agency.team')}}</text>
			</view>
			<hb-table>
				<view slot="header" class="header-th header-th1">
					<text class="header-th-title">{{$t('agency.user')}}</text>
					<text class="header-th-title">{{$t('agency.resign')}}</text>
					<text class="header-th-title">{{$t('agency.profit')}}（coin）</text>
					<text class="header-th-title">{{$t('agency.calculat')}}</text>
				</view>
				<view slot="body">
					<view class="hb-table-body-column hb-table-body-column1" v-if="dataList.length > 0"
						v-for="item in dataList" :class="item.show?'show':''">
						<text class="column-th">{{item.sub_id}}</text>
						<text class="column-th">{{item.date}}</text>
						<text class="column-th">{{Number(item.total_profit)}}</text>
						<text class="column-th">{{Number(item.phs)}}</text>
					</view>
				</view>
			</hb-table>
			<view class="load-more" style="padding-top:20rpx">
				<uniLoadMore :loadingType="loadingType" :contentText="contentText"></uniLoadMore>
			</view>
		</view>
	</view>
</template>

<script>
	import HbHeader from "@/components/hb-header.vue";
	import {
		mapState
	} from 'vuex';
	import uniLoadMore from '@/components/uni-load-more.vue';
	import HbTable from "@/components/hb-table";
	import HbHead from '@/components/hb-head.vue'
	import {
		Profit,
		rewardLog,
	} from '@/api/parent'
	export default {
		components: {
			HbHead,
			HbTable,
			uniLoadMore,
			HbHeader,
		},
		data() {
			return {
				backType: '',
				pullDownLoading: false,
				pullDown: true,
				dataList: [],
				page: 1,
				loadingType: 0,
				alsolt: {},
			}
		},
		mounted() {

		},
		onShow() {
			this.$store.dispatch('getUserProfileAction');
			this.onMyTeam()
			this.getDataList(true);
		},
		created() {
			this.onMyTeam()
			this.getDataList(true);
		},
		watch: {

		},
		computed: {
			...mapState({
				userInfo: state => state.user.userInfo,
				configs: state => state.config.configs
			}),
			contentText() {
				return {
					contentdown: this.$t('info.contentText.contentdown'),
					contentrefresh: this.$t('info.contentText.contentrefresh'),
					contentnomore: this.$t('info.contentText.contentnomore')
				}
			}
		},
		methods: {
			onMyTeam(bol) {
				Profit().then(res => {
					if (res.status == 1) {
						this.alsolt = res.data
					}
				})
			},
			getDataList(bol) {
				this.loadingType = 1;
				var time = Math.round(new Date().getTime() / 1000);
				var data = {
					page: this.page,
					time: time
				}
				rewardLog(data).then(res => {
					if (res.code = '1000') {
						if (bol) {
							this.dataList = [];
						}
						this.total = res.data.miningCount
						let arr = res.data.mining
						this.dataList.push(...arr)
					} else {
						this.loadingType = 3
						this.dataList = [];
					}
				}).catch(() => {
					this.loadingType = 3
					this.dataList = [];
				})
			},
		},
		onPullDownRefresh() {
			this.page = 1;
			this.loadingType = 0;
			this.getDataList(true);
			this.onMyTeam()
			uni.stopPullDownRefresh()
		},
	}
</script>

<style scoped lang="scss">
	.header {
		.back-icon {
			display: block;
			width: 40rpx;
			height: 40rpx;
			padding-left: 18rpx;
			font-size: 36rpx;
		}

		.title {
			color: $hb-title-color;
			font-size: 36rpx;
		}

		.icon {
			display: block;
			width: 56rpx;
			height: 56rpx;
			margin-right: 32rpx;
		}
	}

	.line {
		width: 100%;
		height: 20rpx;
		background: #f5f5f5;
	}

	.top {
		// padding: 30rpx;

		.user {
			// width: 100%;
			// height: 320rpx;
			// background: url(@/static/my/bg-achieve.png)no-repeat;
			// background-size: contain;

			.user-info {
				display: flex;
				align-items: center;
				padding: 30rpx;

				.user-info-name {
					margin-left: 16rpx;
					color: #333;

					.user-name {
						font-size: 34rpx;
						display: block;
					}

					.user-id {
						color: #333;
						font-size: 24rpx;
						display: block;
						margin-top: 10rpx;
					}
				}

				.user-grade {
					// height: 100rpx;
					// margin-top: 12rpx;
					// margin-left: 20rpx;
					// padding-top: 14rpx;
					// box-sizing: border-box;
					position: relative;
					width: 120rpx;
					height: 32rpx;
					line-height: 32rpx;
					font-size: 20rpx;
					text-align: center;
					background: linear-gradient(90deg, rgba(224, 205, 195, 1) 0%, rgba(201, 164, 138, 1) 100%);
					border-radius: 32rpx;
					margin-top: -38rpx;
					margin-left: 10rpx;

					.grade-box {
						position: relative;
						width: 120rpx;
						height: 32rpx;
						line-height: 32rpx;
						font-size: 20rpx;
						text-align: center;
						color: rgba(129, 84, 71, 1);
						font-weight: bold;
						// image {
						// 	width: 100%;
						// 	height: 100%;
						// }
					}

					.pic {
						width: 28rpx;
						height: 28rpx;
						background: url(@/static/my/vip.png)no-repeat;
						background-size: contain;
						border-radius: 50%;
						position: absolute;
						right: 2rpx;
						top: 2rpx;
					}
				}

				.more {
					position: absolute;
					right: 30rpx;
					width: 220rpx;
					height: 60rpx;
					line-height: 60rpx;
					text-align: center;
					font-size: 24rpx;
					color: #C98E65;
					background: rgba(201, 164, 138, .2);
					border-radius: 32rpx;

					text {
						display: inline-block;
						width: 36rpx;
						height: 36rpx;
						border-radius: 50%;
						// margin-right:10rpx;
						background: url(~@/static/my/leftj.png)no-repeat;
						background-size: contain;
						vertical-align: middle;
					}
				}
			}

			.teamtotal {
				padding: 15rpx 30rpx;

				.bg {
					width: 100%;
					height: 80rpx;
					background: url(@/static/my/bg-card2.png)no-repeat;
					background-size: contain;
					text-align: center;
					font-size: 24rpx;
					line-height: 80rpx;
					color: #fff;

					image {
						width: 60rpx;
						height: 49rpx;
						display: inline-block;
						margin-right: 20rpx;
						vertical-align: -10rpx;
					}

					text {
						font-size: 30rpx;
					}
				}

			}
		}
	}

	.moneyChange {
		padding: 30rpx;
		padding-top: 0;

		.content {
			padding: 30rpx;
			background: #383838;
			border-radius: 16rpx;

			.title {
				padding: 30rpx;
				background: linear-gradient(to right, #E0CDC3, #C9A48A);
				border-radius: 16rpx 16rpx 0 0;
				color: #815447;
				height: 54rpx;
				line-height: 54rpx;
				font-size: 28rpx;
				position: relative;

				.team_num {
					font-size: 28rpx;

					text {
						font-size: 36rpx;
						font-family: HarmonyOS_Sans_SC_Medium;
					}
				}

				.team_level {
					display: flex;
					align-items: center;
				}

				// display:flex;
				// align-items:center;
				.sign {
					width: 28rpx;
					height: 28rpx;
					display: inline-block;
					// margin-top:10rpx;
					margin-right: 10rpx;
					vertical-align: middle;
				}

				.p_sign {
					width: 28rpx;
					height: 28rpx;
					position: absolute;
					right: 30rpx;
					top: 40rpx;
				}

				&.center {
					text-align: center;
					font-size: 34rpx;
				}

				&.flex {
					display: flex;
					align-items: center;
				}
			}

			.flexWrap {
				width: 100%;
				display: flex;
				flex-wrap: wrap;
				margin: 40rpx 0 10rpx;
				color: #F0D5B6;

				.item {
					box-sizing: border-box;
					width: 50%;
					text-align: left;
					color: #F0D5B6;
					border-right: .5px solid rgba(240, 231, 182, .1);
					padding-left: 30rpx;

					text {
						display: block;
						font-size: 26rpx;
						margin-bottom: 24rpx;
						color: rgba(240, 213, 182, .7);
					}

					.price {
						font-size: 36rpx;
						padding-bottom: 10rpx;
					}

					.statue {
						font-size: 26rpx;
						color: #FF7374;
					}

					&:nth-child(2) {
						border-right: 0;
						padding-left: 42rpx;
					}
				}

				.wrap {
					border-bottom: 1px solid rgba(240, 231, 182, .1);
					width: 100%;

					.sub {
						font-size: 28rpx;
						margin-bottom: 20rpx;
					}

					.f-item {
						display: flex;
						padding-left: 30rpx;

						.unit {
							flex: 1;

							text {
								display: block;
								font-size: 26rpx;
								margin-bottom: 15rpx;
							}

							.price {
								font-size: 36rpx;
								font-weight: bold;
								padding-bottom: 40rpx;
							}
						}

						&:last-child {
							padding-left: 42rpx;
						}
					}

					&.wr1 {
						border-bottom: 0;
						margin-top: 30rpx;

						.price {
							padding-bottom: 0 !important;
						}
					}
				}
			}
		}
	}

	.priceChange {
		.Tabprice {
			padding: 30rpx;
			font-size: 32rpx;
			color: rgba(38, 38, 40, 1);

			text {
				display: inline-block;
				padding-bottom: 24rpx;
				border-bottom: 3rpx solid rgba(38, 38, 40, 1);
			}
		}
	}

	.header-th {
		width: 100%;
		display: flex;
		align-items: center;
		// margin-bottom: 20rpx;
		padding: 20rpx;
		border-bottom: .5px solid #eee;

		.header-th-title {
			flex: 1;
			// width: 150rpx;
			color: #C6CFD8;
			text-align: left;
			font-size: 26rpx;

			&:nth-child(2) {
				// width: 240rpx !important;
				text-align: center;
			}

			&:nth-child(3) {
				text-align: center;
			}

			&:last-child {
				text-align: right;
				min-width: 160rpx;
				flex: none;
			}
		}

		&.header-th1 {
			.header-th-title {
				&:nth-child(1) {
					// width: 280rpx !important;
					max-width: 120rpx;
				}
			}
		}
	}

	.hb-table-body-column {
		display: flex;
		align-items: center;
		padding: 20rpx;
		border-bottom: .5px solid #eee;
		color: #000;

		&.show {
			color: #C6CFD8;
		}

		.column-th {
			flex: 1;
			text-align: left;
			font-size: 26rpx;
			width: 100rpx;

			&:nth-child(2) {
				// width: 280rpx !important;
				text-align: center;
			}

			&:last-child {
				text-align: right;
			}
		}

		&.hb-table-body-column1 {
			.column-th {
				&:nth-child(1) {
					max-width: 120rpx;
				}

				&:nth-child(3) {
					// width: 110rpx;
					text-align: center;
				}

				&:last-child {
					text-align: right;
					min-width: 160rpx;
					flex: none;
				}
			}
		}

		.succeed {
			color: $hb-text-color
		}

		.no-settlement {
			color: $hb-text-color
		}
	}

	/*发放记录table */
	.grant-header-th {
		.header-th-title {
			// &:first-child {
			// 	width: 140rpx;
			// 	flex: 0 0 140rpx;
			// }

			&:last-child {
				flex: 1;
			}

		}
	}

	.hb-table-body-column.space {
		display: flex;
		justify-content: space-between;

		.column-th {
			&:first-child {
				width: auto !important
			}
		}

	}

	.personpt {
		width: 100%;
		text-align: center;

		image {
			display: inline-block;
			width: 440rpx;
			height: 440rpx;
			margin-top: 70rpx;
		}

		.msg {
			color: rgba(183, 190, 208, 1);
			font-size: 14px;
			line-height: 24px;
			margin-top: 40rpx;
		}
	}

	.apply {
		// position: fixed;
		// bottom: 0;
		// left: 0;
		width: 360rpx;
		height: 100rpx;
		color: rgba(48, 48, 50, 1);
		font-size: 36rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background: linear-gradient(123.03deg, rgba(244, 217, 185, 1) 0%, rgba(223, 154, 87, 1) 100%) !important;
		border-radius: 100rpx;
		border: none !important;
		margin-top: 80rpx;
		color: #fff;

		&.lading {
			background: linear-gradient(123.03deg, rgba(244, 217, 185, .75) 0%, rgba(223, 154, 87, .75) 100%) !important;
			color: rgba(48, 48, 50, .75)
		}

		&:after {
			border: 0
		}
	}

	.choseTab {
		display: flex;
		align-items: center;
		margin: 20rpx;
		border: .5px solid rgba(233, 234, 236, 1);
		border-radius: 6rpx;

		.item {
			flex: 1;
			border-right: .5px solid rgba(233, 234, 236, 1);
			box-sizing: border-box;
			text-align: center;
			line-height: 56rpx;
			font-size: 24rpx;
			color: rgba(183, 190, 208, 1);

			&.active {
				color: rgba(227, 137, 42, 1);
			}

			&:last-child {
				border: 0
			}
		}
	}
</style>
